#include <boost/thread.hpp>
#include <chrono>
#include <thread>
#include <iostream>

int main()
{
    auto f = []() {
        while (1) {
            std::this_thread::sleep_for(std::chrono::seconds(1));
            std::cout << "haha" << std::endl;
            boost::this_thread::interruption_point();
        }
    };
    boost::thread t(f);
    std::this_thread::sleep_for(std::chrono::seconds(3));
    t.interrupt();
    t.join();
}